﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.BLL;
using HRM.DAL.DAO;
using HRM.DAL.Report;

namespace HRM.UI.HigherManagementUI.EmpModule
{
    public partial class DetailsEmployee : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PopulateEmployeeDetails();
        }

        private void PopulateEmployeeDetails()
        {
            Code code = new Code();
            code.CodeName = Request.QueryString["emp-code"];
            ViewEmployee viewEmployee = new ViewEmployee();
            EmployeeManager manager = new EmployeeManager();
            viewEmployee = manager.SearchEmployeeByCode(code);

            //Personal Info
            txtEmpID.Text = code.CodeName;
            txtName.Text = viewEmployee.Employee.Name + ("-");
            txtDesignation.Text = viewEmployee.Designation.Title;
            empImage.ImageUrl = viewEmployee.Photo.FileName;
            txtFname.Text = viewEmployee.Employee.FathersName;
            txtMname.Text = viewEmployee.Employee.MothersName;
            txtSex.Text = viewEmployee.Employee.Sex;
            txtBlood.Text = viewEmployee.Employee.Blood;
            txtDob.Text = (viewEmployee.Employee.DOB).ToShortDateString();
            txtEmail.Text = viewEmployee.Employee.Email;
            txtnationality.Text = viewEmployee.Employee.Nationality;
            txtNID.Text = viewEmployee.Employee.NID;
            //txtMaritialStatus.Text = viewEmployee.Employee.MatitialStatus;


            //Professional Info
            txtEducationlast.Text = viewEmployee.Employee.Education;
            txdesignation.Text = viewEmployee.Designation.Title;
            txtProject.Text = viewEmployee.Project.ProjectName;
            txtCatagory.Text = viewEmployee.Catagory.EmpCatagory;
            txtStatus.Text = viewEmployee.Employee.Status;
            txtJoiningDate.Text = (viewEmployee.Employee.JoiningDate).ToShortDateString();
            txtContatFinishDate.Text = (viewEmployee.Employee.ContractFinishDate).ToShortDateString();


            //contact Info
            txtFirstContact.Text = viewEmployee.Contact.FirstContact;
            txtSecondContact.Text = viewEmployee.Contact.Secondcontact;
            txtECP.Text = viewEmployee.Contact.EmergencyContactPerson;
            txtECN.Text = viewEmployee.Contact.EmergencyContactNumber;
            txtPRADD.Text = viewEmployee.Contact.PresentAddress;
            txtPMADD.Text = viewEmployee.Contact.PermanentAddress;

            //Download Info
            resumeLink.HRef = "~/Resume/" + viewEmployee.Employee.Resume;
            resumeLink.Title = "hhh";


            //LoadCertificate
            CertificateManager certificateManager = new CertificateManager();
            List<Certificate> certificates = new List<Certificate>();
            Certificate certificate = new Certificate();
            Employee employee = new Employee();
            employee.EmpCode = code;
            certificate.Employee = employee;
            certificates = certificateManager.GetCertificates(certificate);
            certificateGdv.DataSource = certificates;
            certificateGdv.DataBind();



        }
    }
}